package com.ssh.service.impl;

import com.ssh.common.ServerResponse;
import com.ssh.dao.UserMapper;
import com.ssh.pojo.User;
import com.ssh.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("iUserService")
public class UserServiceImpl implements IUserService{

    @Autowired
    private UserMapper userMapper;

    @Override
    public ServerResponse<User> login(String name) {
        int resultCount = userMapper.checkName(name);
        if (resultCount == 0){
            return ServerResponse.createByErrorMessage("Valid User!");
        }

        User user = userMapper.selectUser(name);
        return ServerResponse.createBySuccess("correct Name!",user);
    }
}
